<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/product/lib/layui/css/layui.css"/>
		<style type="text/css">
			body{margin:10px auto;width: 750px;}ul{margin-top:5px;}li{margin-top:3px;}.layui-form-switch{margin-top: 0;}#tree1 ul+ul{border-top: 1px dashed #e2e2e2;}
		</style>
	</head>
	<body>
		<button type="button" class="layui-btn layui-btn-primary layui-btn-sm get-checked">获取选中</button>
		<button type="button" class="layui-btn layui-btn-primary layui-btn-sm refresh">刷新（新增）</button>
		<button type="button" class="layui-btn layui-btn-primary layui-btn-sm open-all">全部展开</button>
		<button type="button" class="layui-btn layui-btn-primary layui-btn-sm close-all">全部关闭</button>
		<button type="button" class="layui-btn layui-btn-primary layui-btn-sm change-icon">随机更换小图标</button>
		
		<table class="layui-table layui-form" id="tree-table" ></table>
		
<pre class="layui-code">// 配置参数可自由搭配尝试不同效果
{
	elem: '#tree-table',// 必须
	url: 'data/table-tree.json',// （url和data参数必须设置一个）
	data: [{},{},{},...],
	icon_key: 'title',// 必须
	top_value: 0,
	primary_key: 'id',
	parent_key: 'pid',
	hide_class: 'layui-hide',
	icon: {
		open: 'layui-icon layui-icon-triangle-d',
		close: 'layui-icon layui-icon-triangle-r',
		left: 16,
	},
	cols: [{
		key: 'title',
		title: '名称',
		width: '100px',
		template: function(item){return '显示内容'}
	},{},...],
	checked: {
		key: 'id',
		data: [0,1,4,10,11,5,2,6,7,3,8,9],
	},
	is_click_icon: false,
	is_checkbox: false,
	is_cache: true,
	end: function(e){},
}
</pre>
		
		<script type="text/javascript" src="/product/lib/layui/layui.js"></script>
		<script type="text/javascript">
			layui.config({ base: '/product/lib/modules/'});
			layui.use(['treeTable','layer','code','form','common'],function() {
				let o = layui.$,
						form = layui.form,
						layer = layui.layer,
						treeTable = layui.treeTable;
				let	re = treeTable.render({
					elem: '#tree-table',
					data: [{"id":1,"pid":0,"name":"1-1"},{"id":2,"pid":1,"name":"1-2"}],
					//url: "/product/product/b_product_category/list",
					icon_key: 'name',
					end: function(e){
						form.render();
					},
					cols: [
						{
							key: 'name',
							title: '名称',
							width: '100px',
						}
					]
				});

			});
		</script>
	</body>
</html>
